//package com.xiao.message.rest;
//
//import com.xiao.foundation.web.util.HeaderUtil;
//import com.xiao.message.service.SmsDispatcherService;
//import com.xiao.message.service.dto.SmsCaptchaDTO;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.net.URI;
//import java.net.URISyntaxException;
//import java.util.Optional;
//
//@RestController
//@RequestMapping("/sms")
//@Slf4j
//@Api(tags = "短信收发")
//public class SmsDispatcherResource {
//
//    private SmsDispatcherService smsDispatcherService;
//
//    SmsDispatcherResource(SmsDispatcherService smsDispatcherService) {
//        this.smsDispatcherService = smsDispatcherService;
//    }
//
//    @PostMapping("/captcha")
//    @ApiOperation("请求发送验证码")
//    public ResponseEntity<SmsCaptchaDTO> buildSmsCaptcha(@RequestBody SmsCaptchaDTO smsCaptcha) throws Exception {
//
//        Optional<SmsCaptchaDTO> retOptional = smsDispatcherService.buildSmsCaptcha(smsCaptcha.getPhone());
//        SmsCaptchaDTO smsCaptchaDTO = retOptional.get();
//        HttpHeaders headers = HeaderUtil.createAlert("message", "验证码构造成功!", smsCaptchaDTO.getId());
//        return ResponseEntity.created(new URI("/sms" + "/build/" + smsCaptchaDTO.getId()))
//                .headers(headers).body(smsCaptchaDTO);
//    }
//
//    @PostMapping("/captcha-validated")
//    @ApiOperation("校验验证码")
//    public ResponseEntity<Boolean> validateSmsCaptcha(@RequestBody SmsCaptchaDTO smsCaptcha) throws URISyntaxException {
//        return ResponseEntity.created(new URI("/sms" + "/validated/" + smsCaptcha.getId()))
//                .body(smsDispatcherService.valiadCaptcha(smsCaptcha));
//    }
//
//}
